package ru.amse.ilyin.gui;

import java.awt.Graphics;

import javax.swing.JComponent;

import ru.amse.ilyin.diagram.Diagram;

/**
 * Component for drawing diagrams.
 *
 * @author Alexander Ilyin
 * 
 * @see Diagram
 */
public class DrawingComponent extends JComponent {
	private final Diagram diagram;
	
	/**
	 * Creates new component with the specified diagram.
	 * 
	 * @param diagram diagram to be drawn
	 */
	public DrawingComponent(Diagram diagram) {
		this.diagram = diagram;
	}
	
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		diagram.draw(new AWTRenderer(g));
	}
}